package com.cdy.client.netty;

import com.cdy.client.handler.ResponseHandler;
import com.cdy.common.response.Response;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

/**
 * netty处理器
 *
 * Created by 陈东一
 * 2019/10/19 0019 21:17
 */
@Slf4j
@ChannelHandler.Sharable
public class ClientHandler extends SimpleChannelInboundHandler<Response> {
    
    private final ResponseHandler responseHandler;

    public ClientHandler(ResponseHandler responseHandler) {
        this.responseHandler = responseHandler;
    }

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, Response msg) throws Exception {
        responseHandler.handle(ctx, msg);
    }


}
